import { Body, Controller, Get, Post, Req } from '@nestjs/common';
import { AuthService } from './auth.service';
import { LoginDto } from './dto/login.dto';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get('getInfo')
  async getInfo(@Req() req: any): Promise<any> {
    // 获取用户信息
    return await this.authService.getInfo(req);
  }

  @Get('getRouters')
  getRouters(@Req() req: any) {
    const userId = req.user.userId;
    return this.authService.getRouters(userId);
  }

  @Post('logout')
  async logout(@Req() req: any): Promise<any> {
    return this.authService.logout(req);
  }

  @Get('captchaImage')
  getCaptchaImage() {
    return this.authService.getCaptchaImage();
  }

  @Post('login')
  async login(@Body() data: LoginDto): Promise<any> {
    return this.authService.login(data);
  }
}
